package org.iabako.server.serviceimpl.report;

import org.apache.log4j.Logger;
import org.iabako.server.dao.report.IncomeReportDAO;
import org.iabako.shared.dto.FinancesBalance;
import org.iabako.shared.dto.ReportGenerationInputDTO;
import org.iabako.shared.entity.business.AbstractEntity;
import org.iabako.shared.iservice.report.IncomeReportGeneratorService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.Map;

/**
 * Created by jose on 22/01/15.
 */

@org.springframework.stereotype.Service("incomeReportGeneratorService")
public class IncomeReportGeneratorServiceImpl extends AbstractReportService implements IncomeReportGeneratorService {

    static Logger log = Logger.getLogger(IncomeReportGeneratorServiceImpl.class.getName());

    @Autowired
    IncomeReportDAO reportIncomeDAO;

    @Override
    protected String getReportFileName() {
        return messages.getLabel("report_income_filename");
    }

    @Override
    protected String getReportTitle() {
        return messages.getLabel("report_form_income_title");
    }

    @Override
    protected String getColumnStyleLabel1() {
        return messages.getLabel("report_income_scheduled");
    }

    @Override
    protected String getColumnStyleLabel2() {
        return messages.getLabel("report_income_payed");
    }

    @Override
    protected Double getColumnValue1(FinancesBalance financesBalance) {
        return financesBalance.getSalesReceivable();
    }

    @Override
    protected Double getColumnValue2(FinancesBalance financesBalance) {
        return financesBalance.getSalesPayed();
    }

    public String generateIncomeReport(ReportGenerationInputDTO reportGenerationInputDTO) {
        return generateReport(reportGenerationInputDTO);
    }

    @Override
    protected Map<Object, FinancesBalance> getDataMapByEntity(ReportGenerationInputDTO reportGenerationInputDTO, Date dateAfter, Date date) {
        return reportIncomeDAO.getSalesBy(reportGenerationInputDTO, dateAfter, date);
    }

}

